//
//  CustomLightControlView.m
//  KVideo
//
//  Created by Lin Eidan on 13-9-17.
//  Copyright (c) 2013年 taomee. All rights reserved.
//

#import "CustomLightControlView.h"
#import "UIView+EidanSize.h"
#import "Common.h"

#define  WidthPer       0.9

@implementation CustomLightControlView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor clearColor];
        UIView *bgView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        bgView.backgroundColor=[UIColor blackColor];
        bgView.alpha=0.5;
        [self addSubview:bgView];
        [self setUp];
    }
    return self;
}

-(void)setUp{
    self.lightSliderView=[[SliderControlView alloc] initWithFrame:CGRectMake((self.width*(1-WidthPer))/2, (self.height-self.height)/2, self.width*WidthPer, self.height) andMinValue:0 andLeftBackgroundImageName:@"mov_iconbutton2.png" andRightBg:@"mov_iconbutton1.png" andSliderBtnImageName:@"mov_iconbutton3.png"  andLeftCapWidth:9 andTopCapHight:2.5 andPopImageName:nil andPopViewMove:0 andSliderLabelDisplay:0];
    
    [self.lightSliderView SliderControlSetUpMaxValue:1];
//    self.lightSliderView.backgroundColor=[UIColor purpleColor];
    [self addSubview:self.lightSliderView];
    self.lightSliderView.delegate=self;
    [self.lightSliderView SliderControlSetUpToValue:[[UIScreen mainScreen] brightness]];
//    self.transform=CGAffineTransformMakeRotation(-M_PI * 0.5);
    
}

-(void)SliderControlContinueToValue:(float)toValue{
    [[UIScreen mainScreen] setBrightness:toValue];
    
}

-(float)customLightControlViewGetValue{
    return [[UIScreen mainScreen] brightness];
}

-(void)customLightControlViewSetValue:(float)value{
    [[UIScreen mainScreen] setBrightness:value];
    [self.lightSliderView SliderControlSetUpToValue:value];
}


@end
